package cn.jcet.mapreduce.tables;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @author 鲜磊
 * @Date 2020/12/15 23:13
 */
public class TableBean implements Writable {
    /**
     * id
     * pid
     * amount
     * pname
     * flag
     * @param dataOutput
     * @throws IOException
     */
    private String id;
    private String pid;
    private int amount;
    private String pname;
    private String flag;


    public TableBean() {

    }

    public TableBean(String id, String pid, int amount, String pname, String flag) {
        this.id = id;
        this.pid = pid;
        this.amount = amount;
        this.pname = pname;
        this.flag = flag;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
            dataOutput.writeUTF(id);
            dataOutput.writeUTF(pid);
            dataOutput.writeInt(amount);
            dataOutput.writeUTF(pname);
            dataOutput.writeUTF(flag);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
            id = dataInput.readUTF();
            pid = dataInput.readUTF();
            amount = dataInput.readInt();
            pname = dataInput.readUTF();
            flag = dataInput.readUTF();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPid() {
        return pid;
    }

    public void setPid(String pid) {
        this.pid = pid;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    public String getPname() {
        return pname;
    }

    public void setPname(String pname) {
        this.pname = pname;
    }

    public String getFlag() {
        return flag;
    }

    public void setFlag(String flag) {
        this.flag = flag;
    }

    @Override
    public String toString() {
        return  id + '\t' + amount + "\t" + pname ;
    }
}
